package write_line

import (
	"bufio"
	"fmt"
	"os"
)

func WriteLineTxm(txms []string, name string) {
	filePtr, err := os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0766)
	if err != nil {
		fmt.Println("文件打开失败 [Err:%s]", err.Error())
	}
	defer filePtr.Close()
	//写入文件时，使用带缓存的 *Writer
	write := bufio.NewWriter(filePtr)
	for i := 0; i < len(txms); i++ {
		write.WriteString(txms[i])
		write.WriteString("\n")
	}
	//Flush将缓存的文件真正写入到文件中
	write.Flush()
}
